/*
说明：
以drupal + zen theme为例
功能有 es6转es5， compass编译，监视文件修改

部署方法(忽略nodejs, cnpm, ruby的安装)：
  gem install compass
  cnpm install -g gulp
  cnpm install -g babel
  cd /sites/
  cnpm init
  cnpm install gulp --save-dev
  cnpm install gulp-babel --save-dev
  cnpm install gulp-compass --save-dev
*/

var gulp  = require('gulp');
var babel = require('gulp-babel');
var compass = require('gulp-compass');

gulp.task("js", function () {
  return gulp.src("./sites/all/themes/zen_sub/js/*.es6")
    .pipe(babel())
    .pipe(gulp.dest("./sites/all/themes/zen_sub/js/"));
});

gulp.task('watch_js', function(){
  gulp.watch('./sites/all/themes/zen_sub/js/*.es6', ['js']);
});

gulp.task('css', function() {
  gulp.src('./sites/all/themes/zen_sub/*.scss')
    .pipe(compass({
      project: __dirname+'/sites/all/themes/zen_sub/',
      config_file: 'config.rb'
    }));
});

gulp.task('watch_css', function(){
  gulp.watch(['./sites/all/themes/zen_sub/sass/*.scss', './sites/all/themes/zen_sub/sass/layouts/*.scss'], ['css']);
});

gulp.task('default', function() {
  gulp.start('watch_js', 'watch_css');
});
